<script>
function failure(message){
	//alert(message);
	box_failure = new LightFace({ 
			title: 'Failure', 
			width : 300,
			content: "<div class='failure'>"+message+"</div>"
			,
			buttons: [{ title: 'Cancel', event: function() { this.close();}, color: 'green'}]
		});
		box_failure.open();		
}
//---------------------------------------------------------------------------------------------------->>>> album
function detileShowImages(){
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","detileShowImages",$this->uri->segment(4,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			$('detileShowImages').innerHTML = responseText;
		}
	}).send();
}
//---------------------------------------------------------------------------------------------------->>>> images
function makeCover(){
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","makeCover",$this->uri->segment(3,0),$this->uri->segment(4,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			//$('detileShowImages').innerHTML = responseText;
		}
	}).send();
}
function saveImages(form, evt){
	var msg = "";
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url('project/saveImages')?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				box_images.close();
				showImages();
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}

function saveCommentImages(form, evt) {
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('project','saveCommentImages',$this->uri->segment(4,0)))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
//				box_images.close();
				showCommentImages();
				$('commentImages').set('value','');
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}

function addImagesTrue(){
	box_images = new LightFace.Request({
		width:400,
		height:210,
		url: '<?php echo site_url(array("project","addImagesTrue",$this->uri->segment(3,0)))?>',
		buttons: [
			{ title: 'Save', event: function() { saveImages(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Add Iamges'
	}).open();
}
//---------------------------------------------------------------------------------------------------->>>> show comment album
function showCommentImages(){
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","showCommentImages",$this->uri->segment(4,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			$('showCommentImages').innerHTML = responseText;
		}
	}).send();
}
//---------------------------------------------------------------------------------------------------->>>> edit
function editImages() {
	box_editImages = new LightFace.Request({
		width:400,
		height:160,
		url: '<?php echo site_url(array("project","addEditImages",$this->uri->segment(4,0)))?>',
		buttons: [
			{ title: 'Save', event: function() { saveEditImages(this, event); }, color: 'blue' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Edit Images'
	}).open();
}
function saveEditImages(form, evt) {
	new Event(evt).stop();
	form = $(form);
		form.set('send', {url:'<?php echo site_url(array('project','saveEditImages',$this->uri->segment(4,0)))?>',method :'post',
		 	onSuccess: function(responseText, responseXML){
				box_editImages.close();
				detileShowImages();
				showCommentImages();
//				$('commentAlbum').set('value','');
			},
			onComplete: function(){
				
			},
			onFailure: function(xhr){
				failure();
			}
		});
		form.send();
	
	return false;
}
//---------------------------------------------------------------------------------------------------->>>> delete
function removeImages(){
	box_deleteImages.close();
	var myRequest = new Request({
		url: '<?php echo site_url(array("project","deleteImages",$this->uri->segment(4,0)))?>',
		method: 'post',
		onSuccess : function(responseText){
			//$('showImages').innerHTML = responseText;
			window.location = "<?php echo site_url(array("project","openAlbum",$this->uri->segment(3,0)))?>";
		}
	}).send();
}
function deleteImages(){
	box_deleteImages = new LightFace({
		buttons: [
			{ title: 'Delete', event: function() { removeImages(this, event); }, color: 'green' },
			{ title: 'Cancel', event: function() { this.close(); } }
		],
		title: 'Confirmation',
		content : 'Do you sure to delet this images....!',
	}).open();
}
//---------------------------------------------------------------------------------------------------->>>> formcheck
window.addEvent('domready',function(){
	detileShowImages();
	showCommentImages();
	new FormCheck('formCommentImages', {
		display : {
			errorsLocation : 1,
			showErrors : 1,
			addClassErrorToField : 1
		}
	});
});
</script>
<script type="text/javascript">
//	window.addEvent('domready', function () {
//		new InPlaceEditor($$('.commentAlbum'),$$('.inple_target'));
//		//alert('lsjdkfiksjdbjk');
//	});
</script>

<table bgcolor="#CCCCCC" width="755" border="0" cellspacing="1" cellpadding="0" id="project">
  <tr>
    <td align="center">
    <table bgcolor="#F8F8F8" height="300" width="100%" border="0" cellspacing="5" cellpadding="10">
     
      <tr valign="top">
       <td colspan="2">
       	  <table border="0" align="center" cellpadding="3" cellspacing="2">
     	  <tbody id="detileShowImages"></tbody>
          </table>  
       </td>
      </tr>
      <tr valign="top">
        <td width="150" align="right">
        <a class="uiButton uiAdd" href="javascript: makeCover()" >Make Cover</a><br />
          <a class="uiButton uiAdd" href="javascript: editImages()" >Edit Images</a><br />
		  <a class="uiButton uiAdd" href="javascript: deleteImages()">Delete Images</a>
        </td>
      	<td bgcolor="#F4F4F4">
      	 <table width="100%" border="0" cellpadding="5" cellspacing="0">
     	  <tbody id="showCommentImages"></tbody>
         </table>
         <div align="left">
         	  <form id="formCommentImages" name="formCommentImages" method="post" onsubmit="saveCommentImages(this, event)" enctype="multipart/form-data">
               <textarea class="validate['required']" name="commentImages" id="commentImages" cols="65" rows="3"></textarea>
               <div align="right">
                <input type="submit" class="uiButton uiSave" name="button" id="button" value="Share"/>
               </div>
             </form>
         </div>
      	</td>
      </tr>
    </table></td>
  </tr>
</table>
